//
//  HMStatus.swift
//  Weibo
//
//  Created by ZhuDong on 16/5/24.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HMStatus: NSObject {
    var id: Int64 = 0
    var source: String?
    var created_at: String?
    var text: String?
    var user: HMUser?
    var  pic_urls: [HMPicture]?
    var comments_count: Int = 0
    var reposts_count: Int = 0
    var attitudes_count: Int = 0
    var retweeted_status: HMStatus?
    
    init(dict: [String:AnyObject]) {
        super.init()
        self.setValuesForKeysWithDictionary(dict)
        
    }
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String:AnyObject]{
                 user = HMUser(dict: dict)
            }
            return
        }
        if key == "pic_urls" {
            if let array = value as? [[String:AnyObject]]{
                var arrM: [HMPicture] = [HMPicture]()
                for item in array {
                    arrM.append(HMPicture(dict: item))
                }
                self.pic_urls = arrM
            }
            return
        }
        if key == "retweeted_status" {
            if let dict = value as? [String:AnyObject]{
                retweeted_status = HMStatus(dict: dict)
            }
            return
        }
        super.setValue(value, forKey: key)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        //
    }
}
